package cn.dengta.webapp.trade.model;

import cn.dengta.common.model.State;
import cn.dengta.common.model.ValueProxy;
import cn.dengta.common.model.ValueProxyImpl;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;
import me.codeplayer.util.ArrayUtil;

@Getter
public enum GroupVipLevel implements ValueProxyImpl<GroupVipLevel, Integer> {

	L1(1, "VIP"),
	L2(2, "SVIP"),
	L3(3, "SSVIP", false),
	L4(4, "SUPER VIP", false),
	L5(5, "TOP VIP", false);

	@EnumValue
	public final Integer value;

	final ValueProxy<GroupVipLevel, Integer> proxy;

	GroupVipLevel(Integer value, String label, boolean enabled) {
		this.value = value;
		this.proxy = new ValueProxy<>(this, enabled ? State.PUBLIC : State.PRIVATE, value, label);
	}

	GroupVipLevel(Integer value, String label) {
		this(value, label, true);
	}

	public static final GroupVipLevel[] CACHE = ArrayUtil.filter(GroupVipLevel.values(), t -> t.getProxy().getState().compareTo(State.PUBLIC) >= 0);

	public static GroupVipLevel of(Integer value) {
		return L1.getValueOf(value);
	}

}
